#include <bits/stdc++.h>
using namespace std;
int t;
typedef long long ll;
ll n;
int main(void){
    
    scanf("%d",&t);
    while(t--){
        scanf("%lld",&n);
        ll tmp=n;
        ll ans=1;
        int l=2;
        for(int i=2;i<=200;i++){
            //printf("%lld\n",n);
            if(n>=i){
                ans*=i;
                n-=i;
            }else{
                if(n==0){
                    break;
                }else{
                    if(i-n>=l && i-n<=i-1){
                        //printf("F\n");
                        ans/=(i-n);
                        //printf("1 %lld\n",ans);
                        ans*=i;
                        //printf("2 %lld\n",ans);
                        n+=(i-n);
                        //printf("3 %lld\n",n);
                        n-=i;
                        //printf("4 %lld\n",n);
                    }else{
                        ans/=l;
                        n+=l;
                        l++;
                        i--;
                        continue;
                    }
                }
            }
        }
        if(tmp<=4){
            ans=tmp;
        }
        printf("%lld %lld\n",tmp-1,ans);
    }
    return 0;
}